<div class="container">
  <div class="card mb-3">
    <div class="card-header">{{ t('Profiling') }}</div>
    <div class="card-body">
      <div class="row">
        <div class="col">
          <h3>{{ t('Detailed profile') }}</h3>
          <table class="table table-sm table-striped" id="profiletable">
            <thead>
              <tr>
                <th>{{ t('Order') }} <div class="sorticon"></div></th>
                <th>{{ t('State') }} <div class="sorticon"></div></th>
                <th>{{ t('Time') }} <div class="sorticon"></div></th>
              </tr>
            </thead>
            <tbody>
              {% for state in profiling.profile %}
                <tr>
                  <td>{{ loop.index }}</td>
                  <td>{{ state.status }}</td>
                  <td class="text-end">
                    {{ state.duration }}s
                    <span class="rawvalue hide">{{ state.duration_raw }}</span>
                  </td>
                </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>

        <div class="col">
          <h3>{{ t('Summary by state') }}{{ show_mysql_docu('general-thread-states') }}</h3>
          <table class="table table-sm table-striped" id="profilesummarytable">
            <thead>
              <tr>
                <th>{{ t('State') }} <div class="sorticon"></div></th>
                <th>{{ t('Total Time') }} <div class="sorticon"></div></th>
                <th>{{ t('% Time') }} <div class="sorticon"></div></th>
                <th>{{ t('Calls') }} <div class="sorticon"></div></th>
                <th>{{ t('ø Time', notes = 'Average time') }} <div class="sorticon"></div></th>
              </tr>
            </thead>
            <tbody>
              {% for name, stats in profiling.states %}
                <tr>
                  <td>{{ name }}</td>
                  <td class="text-end">
                    {{ format_number(stats.total_time, 3, 1) }}s
                    <span class="rawvalue hide">{{ stats.total_time }}</span>
                  </td>
                  <td class="text-end">
                    {{ format_number(100 * (stats.total_time / profiling.total_time), 0, 2) }}%
                  </td>
                  <td class="text-end">{{ stats.calls }}</td>
                  <td class="text-end">
                    {{ format_number(stats.total_time / stats.calls, 3, 1) }}s
                    <span class="rawvalue hide">{{ (stats.total_time / stats.calls)|number_format(8, '.', '') }}</span>
                  </td>
                </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>

        <div class="col">
          <canvas id="profilingChartCanvas" data-chart-data="{{ profiling.chart|json_encode|e('html_attr') }}" aria-label="{{ t('Pie chart with profiling results.') }}" role="img"></canvas>
        </div>
      </div>
    </div>
  </div>
</div>
